<!-- /* Description for file.
 * 寻访目标公司
 *
 * @copyright     Copyright 2008-2010, PHInfo Services Inc. (http://www.phinfoservices.com)
 * @package       ues
 * @subpackage    ues/app/views/companymanages
 * @since         ues
 * @version       V0.0.1
 * @modifiedby    张海杰2011年0701
 * @lastmodified  张海杰2011年0701
 */--> 
 <?php	
echo $javascript->link('jquery');
echo $html->css ( 'tab' );
echo $html->css ( 'resumemodels_city' );
echo $javascript->link ( 'checkedAll' );
?>
<script type="text/javascript">
	function mycheck() {
		var  industry1=$("#ResumeIndustry1 option:selected").text();
		var  industry2=$("#ResumeIndustry2 option:selected").text();
		var  company=$("#companyname").val();
		if(industry1=="不限")
		{
			industry1="";
		}
		if(industry2=="不限")
		{
			industry2="";
		}
		if(industry1=="" && industry2=="")
		{
			industry="";
		}
		else
		{
			industry=industry1+"_"+industry2;
		}
		$.post("<?php echo ROOT_WEB_PATH; ?>/companymanages/getCompany/",{
			Industry : industry,
			Company : company
			},
		function(data,textStatus){
				 $(data).find("aaa").each(function(){
				$("#myTable").append("<tr><td><input name=\"checkbox_name\" type=\"checkbox\"/ value="+$(this).attr("name")+"></td><td>"+$(this).text()+"</td></tr>");
			  });
			});
		
		
	}
	
	function myopen()
	{
        window.open("<?php echo ROOT_WEB_PATH; ?>/companymanages/add",'mainFrame2');
	}
	
	function add()
	{
		var delArr = $("input[name='checkbox_name'][checked]");
		var projectid=<?php echo $projectmanagementid;?>;
		if(delArr.length==0)
		{
			alert("请选择一个公司");
			return;
			// $("input:checked").parent().parent().remove(); 删除一行
		}
		var str="";
		for(var i=0;i<delArr.length;i++) {
			var del = delArr[i].value;
			if(del!="")
			{
				str += del;
				str += "/";
			}
		}
		$.post("<?php echo ROOT_WEB_PATH; ?>/companymanages/addTarget/",{
			Companymanages : str,
			Projectid : projectid
			},
		function(data,textStatus){
				 $(data).find("aaa").each(function(){
					 $("#myTable1").append("<tr><td><input name=\"checkbox_name1\" type=\"checkbox\"/ value="+$(this).text()+"></td><td>"+$(this).attr("companyname")+"</td><td>"+$(this).attr("companyCode")+"</td><td>"+$(this).attr("tel")+"</td><td>"+$(this).attr("creater")+"</td> <td>"+$(this).attr("person")+"</td> <td>"+$(this).attr("industry")+"</td><td>"+$(this).attr("companyProperty")+"</td></tr>");
			  });
			});
	}

	function remove()
	{
		var delArr = $("input[name='checkbox_name1'][checked]");
		if(delArr.length==0)
		{
			alert("请选择一个公司");
			return;
			// $("input:checked").parent().parent().remove(); 删除一行
		}
		var str="";
		for(var i=0;i<delArr.length;i++) {
			var del = delArr[i].value;
			if(del!="")
			{
				str += del;
				str += "/";
			}
		}
		var param= [{name:"Companymanages",value:str}];
		 $.ajax({
			  type: 'POST',
			   url: "<?php echo ROOT_WEB_PATH; ?>/companymanages/removeTarget/",
			   async: false,
			   data: param,
			   dataType:"xml",
			   success: function(xml)
			   {
			   }
			 });
		$("input[name='checkbox_name1'][checked]").parent().parent().remove(); //删除一行
	}
	
	
	$(document).ready(function(){
		$("#ResumeIndustry1").change(function(){
			var IndustryDroptoplist = $(this).val();
			if(IndustryDroptoplist!="")
			{
				$.post("<?php echo ROOT_WEB_PATH; ?>/industries/industriesQuery/",{
					Industry : $(this).val()
					},
				function(data,textStatus){
						 $("#ResumeIndustry2:eq(0)>option").remove();
						 $(data).find("aaa").each(function(){
						//	 alert($(this).attr("name"));
						 $("#ResumeIndustry2:eq(0)").append("<option></option>");
						 $("#ResumeIndustry2:eq(0)>option:last").val($(this).attr("name")).html($(this).text());
					  });
					});
			}
			else
			{
				$("#ResumeIndustry2:eq(0)>option").remove();
				$("#ResumeIndustry2:eq(0)").append("<option></option>");
				$("#ResumeIndustry2:eq(0)>option:last").val("").html("不限");
			}
		});
	});	
</script>
<div id="flashMessage"></div>
<!-- 当前位置-->
<div id="tabmenubar">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="tabmenubartitle1"><?php echo  __('YourPosition');//您现在的位置：?></td>
		<td class="tabmenubartitle2"><?php echo __('项目管理');//一级目录
										   echo '>';?>
									<?php echo $html->tag('span', __('寻访目标公司',true));//当前操作地用span加粗?> 						  
		</td>
	</tr>
</table>
</div>
<!-- 当前位置-->
<div class="tabflex">
<fieldset><legend><?php echo __('寻访目标公司',true);?> 	</legend>
<?php echo $form->create('Companymanage',array('action'=>'targertCompany','type'=> 'post','id'=>'usereditform'));?>
<table width="100%" cellspacing="0" cellpadding="0" border="0"
	style="text-align: left">
	<tr>
		<td width="50"></td>
		<td width="100"><?php __('行&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;业：');?></td>
		<td><?php echo $form->input('industry1',array('options'=>$op4,'class' => 'TextBoxE1','id'=>'ResumeIndustry1','div'=>false,'label'=>false));?>
		<?php echo $form->input('industry2',array('options'=>$industrys2List,'class' => 'TextBoxE1','id'=>'ResumeIndustry2','div'=>false,'label'=>false));?></td>
	</tr>
	<tr>
		<td width="50"></td>
		<td width="100"><?php __('名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称：');?></td>
		<td><?php echo $form->input('companyname',array('class' => 'TextBoxE3','div'=>false,'label'=>false,'id'=>'companyname'));?>
		&nbsp;&nbsp;&nbsp;
		<?php echo $form->button('查',array('type'=>'button','onclick'=>'mycheck()'));?></td>
	
	</tr>
</table>
	</fieldset>
</div>	
<?php echo $form->end();?>

<div  class="tabflex">
			<table cellpadding="0" cellspacing="0" class="tab1" id="myTable">
		<tr>
			<th width="30px" height="5px">
			<?php echo $form->create('Companymanage1',array('id'=>'companya'));?>
			<?php echo $form->checkbox('aa',array('id'=>'checkedAll','checked'=>"false",'value'=>"0"));?>
			<?php echo $form->end();?>
			</th>
			<th><?php echo "公司名称";?></th>
		</tr>
		
		</table>
</div>

<div  class="tabflex">
<table width="50%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td width="100px">
			 <a href="javascript:myopen()"><?php echo $html->image('add.gif', 
			 							array('alt' =>  __('Add', true),'title'=>'添加新公司','border'=>'0' )); ?>&nbsp;添加新公司</a>
			</td><!--  __('Add', true) 新增省份-->
				<td width="100px">
			 <a href="javascript:add()"><?php echo $html->image('add.gif', 
			 							array('alt' =>  __('Add', true),'title'=>'添加','border'=>'0' )); ?>&nbsp;添加</a>
			</td><!--  __('Set', true) 新增城市-->
			<td width="100px">
			 <a href="javascript:remove()"><?php echo $html->image('setting.gif', 
			 							array('alt' =>  __('Set', true),'title'=>'删除','border'=>'0' )); ?>&nbsp;删除</a>
			</td><!--  __('Set', true) 自定义城市-->
			<td></td>
					
		</tr>
	</table>
</div>

<div  class="tabflex">
		<table cellpadding="0" cellspacing="0" class="tab1" id="myTable1">
		<tr>
			<th width="30px">
			<?php echo $form->create('Companymanage',array('id'=>'targetcompany'));?>
			<?php echo $form->checkbox('bb',array('id'=>'checkedAll1','checked'=>"false",'value'=>"0"));?>
			
			</th>
			<th><?php echo "公司名称";?></th>
			<th><?php echo "客户编号";?></th>
			<th><?php echo "公司电话";?></th>
			<th><?php echo "公司创建人";?></th>
			<th><?php echo "目标公司添加人";?></th>
			<th><?php echo "行业";?></th>
			<th><?php echo "公司属性";?></th>
		</tr>
		<?php 
		foreach ($targets as $target){
		?>
		<tr>
		<td><?php echo $form->checkbox('id',array('name'=>'checkbox_name1','checked'=>"false",'value'=>$target['Targetcompany']['id']));?></td>
		<td><?php echo $target['Companymanage']['name']?></td>
		<td><?php echo $target['Companymanage']['companyCode']?></td>
		<td><?php echo $target['Companymanage']['tel']?></td>
		<td><?php echo $target['Companymanage']['creater']?></td>
		<td><?php echo $target['Targetcompany']['creater']?></td>
		<td><?php echo $target['Companymanage']['industry']?></td>
		<td><?php echo $target['Companymanage']['companyProperty']?></td>
		</tr>
		<?php }?>
		</table>
		<?php echo $form->end();?>
</div>


